import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.Arrays;

public class 递增三元组 {

    static int[] a ;
    static int[] b ;
    static int[] c ;
    static int[] cnt;
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintStream out = new PrintStream(System.out);
        int n = Integer.parseInt(in.readLine());
        a = new int[n+1];b = new int[n+1];c = new int[n+1];cnt = new int[n+1];

        String[] str1 = in.readLine().split(" ");
        String[] str2 = in.readLine().split(" ");
        String[] str3 = in.readLine().split(" ");

        for (int i=1;i<=n;i++) {
            a[i] = Integer.parseInt(str1[i-1]);
            b[i] = Integer.parseInt(str2[i-1]);
            c[i] = Integer.parseInt(str3[i-1]);
        }
        Arrays.sort(a);Arrays.sort(b);Arrays.sort(c);

        for (int i = 1; i <=n ; i++) {
            for (int j = n; j >= 1; j++) {
                if (b[i] > a[j]) cnt[i]++;
                else if (b[i] > a[n]) {
                    cnt[i] = n;
                    break;
                } else break;
            }
        }


        int count = 0;
        for (int i = 1; i <=n ; i++) {
            for (int j = 1; j <=n ; j++) {
                if(c[i]>b[j]) count += cnt[j];
                else break;
            }
        }

        System.out.println(count);
    }
}
